Binary Search Visualization



Enter a Sorted Array and a Target value to search



OVERVIEW

Binary Search Algorithm is a searching algorithm used in a sorted array by repeatedly dividing the search interval in half. The idea of binary search is to use the information that the array is sorted and reduce the time complexity to O(log N).

Steps
  • Find the middle element of the array.
  • If it matches the target, return its index.
  • If the target is smaller, search the left half.
  • If the target is larger, search the right half.
  • Repeat until the element is found or the array is exhausted.